//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package cn.fan.model;

//import com.cdtye.common.mongocore.base.BaseVo;
import cn.fan.model.vo.BaseVo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Page<T> implements Serializable {
    private Integer page = 1;
    private Integer size = 30;
    private long total;
    private List<T> records;

    public Page() {
        this.total = 0L;
        this.records = new ArrayList();
    }

    public Page(Integer page, Integer size, List<T> records, long total) {
        this.page = page;
        this.size = size;
        this.total = total;
        this.records = records;
    }

    public Page(List<T> records, long total) {
        this.total = total;
        this.records = records;
    }

    public Page(List<T> records, long total, BaseVo vo) {
        this.total = total;
        this.records = records;
        this.page = vo.getPage();
        this.size = vo.getSize();
    }

    public static Long getTotalPage(Long total, int pageSize) {
        if (total < (long)pageSize) {
            return 1L;
        } else {
            return total % (long)pageSize != 0L ? total / (long)pageSize + 1L : total / (long)pageSize;
        }
    }

    public Integer getPage() {
        return this.page;
    }

    public Integer getSize() {
        return this.size;
    }

    public long getTotal() {
        return this.total;
    }

    public List<T> getRecords() {
        return this.records;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Page)) {
            return false;
        } else {
            Page<?> other = (Page)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$page = this.getPage();
                Object other$page = other.getPage();
                if (this$page == null) {
                    if (other$page != null) {
                        return false;
                    }
                } else if (!this$page.equals(other$page)) {
                    return false;
                }

                Object this$size = this.getSize();
                Object other$size = other.getSize();
                if (this$size == null) {
                    if (other$size != null) {
                        return false;
                    }
                } else if (!this$size.equals(other$size)) {
                    return false;
                }

                if (this.getTotal() != other.getTotal()) {
                    return false;
                } else {
                    Object this$records = this.getRecords();
                    Object other$records = other.getRecords();
                    if (this$records == null) {
                        if (other$records != null) {
                            return false;
                        }
                    } else if (!this$records.equals(other$records)) {
                        return false;
                    }

                    return true;
                }
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof Page;
    }

    public int hashCode() {
//        int PRIME = true;
        int result = 1;
        Object $page = this.getPage();
        result = result * 59 + ($page == null ? 43 : $page.hashCode());
        Object $size = this.getSize();
        result = result * 59 + ($size == null ? 43 : $size.hashCode());
        long $total = this.getTotal();
        result = result * 59 + (int)($total >>> 32 ^ $total);
        Object $records = this.getRecords();
        result = result * 59 + ($records == null ? 43 : $records.hashCode());
        return result;
    }

    public String toString() {
        return "Page(page=" + this.getPage() + ", size=" + this.getSize() + ", total=" + this.getTotal() + ", records=" + this.getRecords() + ")";
    }
}
